package gov.pbc.nn.kjgl.item.template.handler;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.springframework.stereotype.Component;

import com.bstek.bdf2.core.business.IUser;
import com.bstek.bdf2.core.context.ContextHolder;
import com.bstek.uflo.env.Context;
import com.bstek.uflo.model.ProcessInstance;
import com.bstek.uflo.process.handler.AssignmentHandler;
import com.bstek.uflo.process.node.TaskNode;

import gov.pbc.nn.core.bdf.entity.Dept;
import gov.pbc.nn.core.utils.SecurityUtils;
import gov.pbc.nn.kjgl.Constants;

/**
 * 盖章节点，使用该类获取任务处理人
 * 
 * @author Administrator
 * 
 */
@Component("gov.pbc.nn.kjgl.item.template.handler.StampAssignmentHandler")
public class StampAssignmentHandler implements AssignmentHandler {

	@Override
	public Collection<String> handle(TaskNode arg0, ProcessInstance arg1, Context arg2) {
		String deptId = ((Dept) ContextHolder.getLoginUser().getDepts().get(0)).getCDept().getId();

		List<IUser> list = SecurityUtils.getUserByRoleForDeptWithChildren(deptId, Constants.ROLE_GZY);
		List<String> users = new ArrayList<String>();
		for (IUser user : list) {
			users.add(user.getUsername());
		}
		return users;
	}

}
